﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using InstrumentCheck.Module;

namespace InstrumentCheck.ILocalService
{
    public class FormService : IFormService
    {
        public event EventHandler<FormApproveEvntArgs> OnStaffSubmit;
        public event EventHandler<FormApproveEvntArgs> OnStaffCancel;
        public event EventHandler<FormApproveEvntArgs> OnStaffSave;

        public event EventHandler<FormApproveEvntArgs> OnApprove;
        public event EventHandler<FormRejectEvntArgs> OnReject;

        //public event EventHandler<FormRejectEvntArgs> OnRejected;
        //public event EventHandler<FormRejectEvntArgs> OnRejectToBoss;
        //public event EventHandler<FormRejectEvntArgs> OnRejectToCorrectRoom;

        #region 申请者的event
        public void RaiseStaffSubmitEvent(FormApproveEvntArgs e)
        {
            if (OnStaffSubmit != null)
            {
                e.WaitForIdle = true;
                OnStaffSubmit(null, e);
            }
        }
        public void RaiseStaffSaveEvent(FormApproveEvntArgs e)
        {
            if (OnStaffSave != null)
            {
                e.WaitForIdle = true;
                OnStaffSave(null, e);
            }
        }
        public void RaiseStaffCancelEvent(FormApproveEvntArgs e)
        {
            if (OnStaffCancel != null)
            {
                e.WaitForIdle = true;
                OnStaffCancel(null, e);
            }
        }
        #endregion

        #region 拒绝的事件
        //public void RaiseRejectedEvent(FormRejectEvntArgs e)
        //{
        //    if (OnReject != null)
        //    {                
        //        e.WaitForIdle = true;
        //        OnRejected(null, e);
        //    }
        //}
        //public void RaiseRejectToBossEvent(FormRejectEvntArgs e)
        //{
        //    if (OnRejectToBoss != null)
        //    {
        //        e.WaitForIdle = true;
        //        OnRejectToBoss(null, e);
        //    }
        //}
        //public void RaiseRejectToCorrectRoomEvent(FormRejectEvntArgs e)
        //{
        //    if (OnRejectToCorrectRoom != null)
        //    {
        //        e.WaitForIdle = true;
        //        OnRejectToCorrectRoom(null, e);
        //    }
        //}
        public void RaiseRejectEvent(FormRejectEvntArgs e)
        {
            if (OnReject != null)
            {
                e.WaitForIdle = true;
                OnReject(null, e);              
            }
        }
        
        #endregion

        #region  同意签核的事件
        public void RaiseApproveEvent(FormApproveEvntArgs e)
        {
            if (OnApprove != null)
            {
                e.WaitForIdle = true;
                OnApprove(null, e);
            }
        }
        #endregion
    }
}
